home *** CD-ROM | disk | FTP | other *** search
- /**************************************************************************
- *
- * @@@BUILDINFO@@@ 04window.jsx 1.0.0.48 07-Feb-2005
- * Copyright 2005 Adobe Systems Incorporated
- * All Rights Reserved.
- *
- * NOTICE: All information contained herein is, and remains the property of
- * Adobe Systems Incorporated and its suppliers, if any. The intellectual
- * and technical concepts contained herein are proprietary to Adobe Systems
- * Incorporated and its suppliers and may be covered by U.S. and Foreign
- * Patents,patents in process,and are protected by trade secret or copyright
- * law. Dissemination of this information or reproduction of this material
- * is strictly forbidden unless prior written permission is obtained from
- * Adobe Systems Incorporated.
- **************************************************************************/
-
- // Additions to the Window object.
-
- // Iterate through all of the BridgeTalk interface definitions attached to
- // the BridgeTalk object and load the apps listbox with all display names.
- // Attach the BridgeTalk name to every list item.
-
- Window.prototype.loadApps = function()
- {
- // add myself
- this.addApplication (BridgeTalk.appSpecifier, window.title);
-
- var i;
- // First, get the BT specifiers for the most recent installed apps
- var latestApps = BridgeTalk.getTargets (null, null);
- // set the BT specifiers as properties for easier lookup
- for (var i = 0; i < latestApps.length; i++)
- latestApps [latestApps [i]] = true;
- // we want to offer all possible targets
- var apps = BridgeTalk.getTargets (-999, null);
- var curLocale = $.locale.toLowerCase();
-
- // determine for each app if version and/or locale info needs to be added
- // collect this stuff into the following object, create subobjects holding
- // booleans for versions and locales needed
- var testObj = {};
- for (var pass = 1; pass <= 2; pass++)
- {
- for (var i = 0; i < apps.length; i++)
- {
- // the target is now fully qualified
- var app = apps [i];
- var target = app.split ('-');
- var version = target [1];
- var locale = target [2];
- target = target [0];
- // Ignore the Help Center for now
- if (target == "helpcenter")
- continue;
- // do not load info about myself
- if (target != BridgeTalk.appName)
- {
- var appObj = testObj [target];
- if (!appObj)
- appObj = testObj [target] =
- { needVersion:false, needLocale:false, version:version, locale:locale };
- if (pass == 1)
- {
- // pass 1: collect information
- if (appObj.version != version)
- appObj.needVersion = true;
- if (appObj.locale != locale)
- appObj.needLocale = true;
- }
- else
- {
- // pass 2: generate the entries
- var displayName = BridgeTalk.getDisplayName (app);
- // OK, the dislay name is valid - we can use it
- if (displayName)
- {
- // need to add version and/or locale?
- if (appObj.needVersion && appObj.needLocale)
- displayName += " (" + version + ", " + locale + ")";
- else if (appObj.needVersion)
- displayName += " (" + version + ")";
- else if (appObj.needLocale)
- displayName += " (" + locale + ")";
- this.addApplication (app, displayName);
- }
- }
- }
- }
- }
- }
-
- // Add an app to the Apps drop-down box.
-
- Window.prototype.addApplication = function (target, name)
- {
- // overcome an installer bug
- if (name.length > 4)
- {
- var index = name.lastIndexOf (".app");
- if (index == name.length - 4)
- name = name.substr (0, index);
- }
- // Capitalize the first character (for apps that connect directly)
- if (name [0] >= 'a' && name [0] <= 'z')
- name = name.toUpperCase()[0] + name.substr (1);
- BridgeTalk.addTarget (target, name);
- this.apps.add ("item", name);
- }
-
- // Add an engine.
-
- Window.prototype.addEngine = function (engine)
- {
- var item = this.engines.add ("item", engine);
- this.engines.all [engine] = item;
- }
-
- // Add the engines to the Engines drop-down list
-
- Window.prototype.setupEngines = function (target)
- {
- this.engines.removeAll();
- this.engines.all = {};
-
- var debuggers = Debugger.getAll (target);
- for (var i = 0; i < debuggers.length; i++)
- {
- var dbg = debuggers [i];
- this.addEngine (dbg.engine);
- this.setEngineState (dbg);
- }
- }
-
- // Reflect the state of the given debugger into the Engines drop-down.
- // If there is no debugger supplied, use the current debugger.
-
- Window.prototype.setEngineState = function (dbg)
- {
- if (!dbg)
- dbg = currentDebugger;
- if (dbg)
- {
- var engine = dbg.engine;
- var item = this.engines.all [engine];
- if (item)
- {
- switch (dbg.state)
- {
- case Debugger.RUNNING: item.icon = "RunningEngine"; break;
- case Debugger.STOPPED: item.icon = "StoppedEngine"; break;
- case Debugger.WAITING: item.icon = "WaitingEngine"; break;
- default: item.icon = "InactiveEngine";
- }
- }
- }
- }
-
- // Select an application/engine combination.
- // the app name is the BridgeTalk name. If the engine name is omitted,
- // clear all engines.
-
- Window.prototype.selectAppAndEngine = function (target, engine)
- {
- var displayName = BridgeTalk.getTargetDisplayName (target);
- if (displayName)
- this.apps.selection = this.apps.find (displayName);
- if (engine)
- {
- item = this.engines.all [engine];
- if (item)
- this.engines.selection = item;
- }
- else
- this.engines.removeAll();
- }
-
- // Selection callback for the Applications combobox.
- // This routine always connects to the target and
- // sees if it is up and running. The Debugger.connect()
- // method fills in the list of engines and sets up the
- // Engines combobox.
-
- window.apps.onChange = function()
- {
- if (this.selection)
- {
- // find the target name for the selection
- var target = BridgeTalk.getTargetByDisplayName (this.selection.text);
- if (target && BridgeTalk.launchTarget (target))
- Debugger.connect (target);
- }
- }
-
- // Define the callback for the engine selection combobox in the toolbar
-
- window.engines.onChange = function()
- {
- if (this.selection)
- {
- var target = BridgeTalk.getTargetByDisplayName (window.apps.selection.text);
- var engine = this.selection.text;
- var dbg = null;
- if (engine && target)
- dbg = Debugger.find (target, engine);
- if (dbg)
- // there is a debugger active for this engine. Bring that doc to the front!
- dbg.activate();
- else
- currentDebugger.activate();
- }
- }
-